#include<iostream>
using namespace std;
const int N = 1e3 + 10;
int arr[N];
int main()
{
	int n;
	cin >> n;
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
		sum ^= arr[i];
	}
	for (int i = 0; i < arr[1]; i++) {
		for (int j = 1; j <= n; j++) {
			int x1 = arr[i] - j;
			int x2 = arr[j] + j;
			int temp = sum ^ x1 ^ x2 ^ arr[1] ^ arr[j];
			if (!temp) {
				cout << i << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;
	return 0;
}